package cc.comac.mom.api;

import javax.servlet.http.HttpServletResponse;

import cc.comac.mom.entity.QualityAttachmentEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import cc.comac.mom.bean.QualityAttachment;
import cc.comac.mom.config.FeignMultipartSupportConfig;
import cc.comac.mom.util.ResultBean;

@FeignClient(name = "mom-qar-srv",configuration = FeignMultipartSupportConfig.class)
public interface QualityAttachmentService {
	//文件上传
	@PostMapping(value="/p/cs/QualityAttachmentService/uploadFile",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	public ResultBean uploadFile(@RequestPart("files") MultipartFile[] files);
	
	//文件上传不保存附件表，用于不分组的表结构
	@PostMapping(value="/p/cs/QualityAttachmentService/uploadFileNoGroup",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	public ResultBean uploadFileNoGroup(@RequestPart("files") MultipartFile[] files);
	
	//删除文件
	@RequestMapping(value="/p/cs/QualityAttachmentService/deleteFileByAttachmentId",method = RequestMethod.POST)
	public ResultBean deleteFileByAttachmentId(@RequestParam(value = "attachmentId") long attachmentId);
	
	//获取文件组id
	@RequestMapping(value="/p/cs/QualityAttachmentService/getByAttachmentGroupId",method = RequestMethod.POST)
	public ResultBean getByAttachmentGroupId(@RequestParam(value = "groupId") long groupId);
	
	//附件下载
	@RequestMapping(value = "/p/cs/QualityAttachmentService/download",method = RequestMethod.POST)
	public ResultBean download (@RequestParam(value = "attachmentId") Long attachmentId, @RequestParam(value = "response") HttpServletResponse response);
	
	@RequestMapping(value = "/p/cs/QualityAttachmentService/getByAttachmentId")
	public QualityAttachmentEntity getByAttachmentId(@RequestParam(value = "attachmentId") Long attachmentId);
	
}
